package mediatheque.controller;

import mediatheque.model.CdromModel;
import mediatheque.model.MediathequeModel;
import mediatheque.view.CdromView;

public class CdromController extends DocumentController {

	public CdromController(MediathequeModel model, final CdromView view) {
		this(model, view, null);		
	}
	
	public CdromController(MediathequeModel model, final CdromView view, CdromModel cdrom) {
		super(model, view, cdrom);
	}

	protected boolean verifierChamps() {
		return (super.verifierChamps() && !((CdromView) view).getValeurMarque().isEmpty());
	}

	protected void enregistrer() {
		if(document == null){
			document = new CdromModel();
			model.ajouterDocument(document.getIdentifiant(), (CdromModel)document);
		}

		((CdromModel) document).setMarque(((CdromView) view).getValeurMarque());
		
		super.enregistrer();
	}	
}
